http = require 'http'
url = require 'url'
server = http.createServer (request, response) ->
	requestUrl = url.parse request.url, true
	path = requestUrl.pathname
	date = new Date requestUrl.query.iso
	result
	if /\/api\/parsetime/.test path
		result = {hour : date.getHours(), minute : date.getMinutes(), second : date.getSeconds()}
	else if /\/api\/unixtime/.test path
		result = {unixtime : date.getTime()}
	return 	response.end JSON.stringify result
server.listen process.argv[2]